// 瀑布流商品预览
Component({
  properties: {
    data: Object,
  },

  data: {
    tags: Array,
  },

  observers: {
    data: function (data) {
      if (!data) {
        return;
      }
      if (!data.tags) {
        return;
      }
      const tags = data.tags.split("$");
      // console.log(tags);
      this.setData({
        tags,
      });
    },
  },

  methods: {
    onImgLoad(event) {
      const { width, height } = event.detail;
      this.setData({
        w: 340,
        h: (340 * height) / width,
      });
    },
    onItemTap(event) {
      // 商品ID
      const pid = event.currentTarget.dataset.pid;
      wx.navigateTo({
        url: `/pages/detail/detail?pid=${pid}`,
      });
    },
  },
});
